<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/jsp/common/taglibs.jsp"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<jsp:include page="/WEB-INF/jsp/common/include_assets.jsp"></jsp:include>
<jsp:include page="/WEB-INF/jsp/common/include_easyui_only.jsp"></jsp:include>
 <title>权限管理系统</title>
<style>	
  .west{
    width:200px;
    padding:10px;
  }
.footer{text-align:center;color:#15428B; margin:0px; padding:0px;line-height:22px;  background: #D2E0F2; }  
.panel-body{
    padding: 0px;
    overflow: hidden;
}
#footer.panel-body ,#header.panel-body ,#content.panel-body{
    border:none;
}



</style> 
</head>
<body class="easyui-layout" style="overflow-y: hidden"  scroll="no">
    <div id="header" region="north" split="false" border="false" style="overflow: hidden; height: 60px;
        line-height: 20px;color: #fff;">
		<jsp:include page="/WEB-INF/jsp/header.jsp"></jsp:include>
    </div>

	<div region="center" id="content" >
		  <div class="easyui-tabs" border="false" id="tabs" data-options="tabWidth:160,fit:true">	      
				<div title="首页" style="overflow:hidden;" id="home">
					<iframe scrolling="auto"  frameborder="0" style="width:100%;height:100%;overflow-x:hidden " 
						src="<c:url value="/mainController/welcomePage"></c:url>"></iframe>
		  		</div>	
		  </div>
	</div>

  
	<div region="west" class="west" title="导航菜单" style="padding: 0px;margin: 0px;">
		<%-- 默认树形菜单 --%>
		<c:if test="${empty configParam || configParam.leftMenu=='tree'}">
			<ul id="div_tree"></ul>
		</c:if>
		<%-- 可折叠菜单 --%>
		<c:if test="${not empty configParam && configParam.leftMenu!='tree'}">
			<div class="easyui-accordion" data-options="fit:true">
				<c:forEach var="rowMap" items="${parentList}">
					<div title="${rowMap.text}" icon="icon-sys" style="overflow: auto;">
						<div id="div_tree_${rowMap.id}"></div>
					</div>
				</c:forEach>
			</div>
		</c:if>
	</div>
  
    <div id="footer" region="south" border="false" split="false" style="height: 40px;" data-options="border:false">
        <jsp:include page="/WEB-INF/jsp/footer.jsp"></jsp:include>
    </div>
  
	<div id=mm class="easyui-menu" style="width:150px;">
		<div id="mm-tabclose">关闭</div>
		<div id="mm-tabcloseall">全部关闭</div>
		<div id="mm-tabcloseother">除此之外全部关闭</div>
		<div class="menu-sep"></div>
		<div id="mm-tabcloseright">当前页右侧全部关闭</div>
		<div id="mm-tabcloseleft">当前页左侧全部关闭</div>
		<div class="menu-sep"></div>
		<div id="mm-exit">退出</div>
	</div>  
<script> 
$(function(){
 
  	<%-- 树形菜单（默认） --%>
	<c:if test="${empty configParam || configParam.leftMenu=='tree'}">
		//动态菜单数据
		var loadURL = "<%=path%>/mainController/loadUserMenu";
		//实例化树形菜单
		jQuery("#div_tree").tree({
			lines:			true,
			url:			loadURL,	
			onClick:		function(node){
				var isLeaf = 		node.isLeaf;
				var menu_name = 	node.text;
				var menu_href = 	"<%=path%>" + node.menuHref;
				//window.alert(menu_href);
				if (isLeaf == 1){
					addTab(menu_name,menu_href,"icon-tip");
				}
			}
		});
	</c:if>
	<%-- 可折叠菜单 --%>
	<c:if test="${not empty configParam && configParam.leftMenu!='tree'}">
	//动态菜单数据
	  <c:forEach var="rowMap" items="${parentList}">
	  	  var id = "${rowMap.id}";  	  
		  var loadURL = "<%=path%>/mainController/loadUserMenu?parentId="+id+"";
		  //实例化树形菜单
		  jQuery("#div_tree_"+id+"").tree({
		    lines:			true,
		    url:			loadURL,	
		    onClick:		function(node){
		    	var isLeaf = 		node.isLeaf;
		    	var menu_name = 	node.text;
		    	var menu_href = 	"<%=path%>" + node.menuHref;
		    	//window.alert(menu_href);
		    	if (isLeaf == 1){
		    		addTab(menu_name,menu_href,"icon-tip");
		    	}
		    }
		  }); 
	  </c:forEach>
	</c:if>
  
  
function addTab(subtitle,url,icon){
	if(!$('#tabs').tabs('exists',subtitle)){
		$('#tabs').tabs('add',{
			title:				subtitle,
			content:			'<iframe scrolling="auto" frameborder="0"  src="'+url+'" style="width:100%;height:100%;"></iframe>',
			closable:			true,
			iconCls:			icon
		});
	}else{
		$('#tabs').tabs('select',subtitle);
	}
	tabClose();
}
	  
	function tabClose()
	{
		/*双击关闭TAB选项卡*/
		$(".tabs-inner").dblclick(function(){
			var subtitle = $(this).children(".tabs-closable").text();
			$('#tabs').tabs('close',subtitle);
		})
		/*为选项卡绑定右键*/
		$(".tabs-inner").bind('contextmenu',function(e){
			$('#mm').menu('show', {
				left: e.pageX,
				top: e.pageY
			});
			
			var subtitle =$(this).children(".tabs-closable").text();
			
			$('#mm').data("currtab",subtitle);
			$('#tabs').tabs('select',subtitle);
			return false;
		});
	}
	//绑定右键菜单事件

	$("#editPersonInfoBtn").click(function(){
		var editURL = "<%=path%>/userPersonalController/preModifyPersonalInfo?date="+new Date()+"";
		addTab("修改信息",editURL,"icon-tip");
	});
	$("#modifyPwdBtn").click(function(){
		var modifyURL = "<%=path%>/userPersonalController/preModifyPersonalPwd?date="+new Date()+"";
		addTab("修改密码",modifyURL,"icon-tip");
	});
	$("#logoutBtn").click(function(){
		$.messager.confirm('注销提示','您确认要退出系统吗？',function(tag){    
		    if (tag){    
		    	location.href = "/bfs/securityController/logout";   
		    }    
		});
		
	});
	
	
	//关闭当前
	$('#mm-tabclose').click(function(){
		var currtab_title = $('#mm').data("currtab");
		$('#tabs').tabs('close',currtab_title);
	})
	//全部关闭
	$('#mm-tabcloseall').click(function(){	
		$('.tabs-inner span').each(function(i,n){
			var t = $(n).text();
			if (t != "首页"){
				$('#tabs').tabs('close',t);
			}
			
		});	
	});
	//关闭除当前之外的TAB
	$('#mm-tabcloseother').click(function(){
		var currtab_title = $('#mm').data("currtab");
		$('.tabs-inner span').each(function(i,n){
			var t = $(n).text();
			if (t != "首页"){
				if(t!=currtab_title)
					$('#tabs').tabs('close',t);
			}
		});	
	});
	//关闭当前右侧的TAB
	$('#mm-tabcloseright').click(function(){
		var nextall = $('.tabs-selected').nextAll();
		if(nextall.length==0){
			//msgShow('系统提示','后边没有啦~~','error');
			alert('后边没有啦~~');
			return false;
		}
		nextall.each(function(i,n){
			var t=$('a:eq(0) span',$(n)).text();
			if (t != "首页"){
				$('#tabs').tabs('close',t);
			}
		});
		return false;
	});
	//关闭当前左侧的TAB
	$('#mm-tabcloseleft').click(function(){
		var prevall = $('.tabs-selected').prevAll();
		if(prevall.length==0){
			alert('到头了，前边没有啦~~');
			return false;
		}
		prevall.each(function(i,n){
			var t=$('a:eq(0) span',$(n)).text();
			
			if (t != "首页"){
				$('#tabs').tabs('close',t);
			}
		});
		return false;
	});
	
	//退出
	$("#mm-exit").click(function(){
		$('#mm').menu('hide');
	})
});
</script>
</body>
</html>